import uuid

node_name_uuid = str(uuid.uuid5(uuid.NAMESPACE_DNS, "2427G 29 Garcia d Avila [Sir Galahad]"))
print(node_name_uuid)

import os
import requests
import time
from kg_server import KGServer

# kg_server = KGServer()
# node_type = 'Ship'
# filepath = os.path.join(os.path.dirname(__file__), "%s.txt" % node_type)


# print(filepath)
# def load_data():
#     res = kg_server.select("MATCH (n:%s {ShipID:'2427'}) RETURN n" % node_type)
#     f = open(filepath, 'w')
#     for record in res:
#         node_data = kg_server.record2properties(record)
#         node_name_uuid = str(uuid.uuid5(uuid.NAMESPACE_DNS,
#                                         "{node_id}{node_name}".format(node_id=node_data['%sID' % node_type],
#                                                                       node_name=node_data['name'])))
#         f.write("%s,%s\n" % (node_data['%sID' % node_type], node_name_uuid))
#     f.close()
#
#
# def save_data():
#     with open(filepath, 'r') as f:
#         for line in f:
#             ID, node_name_uuid = line.strip().split(',')
#             data = {'ID': ID, 'node_name_uuid': node_name_uuid, 'node_type': node_type}
#             res = requests.post("http://localhost:5000/update", data=data).json()
#             time.sleep(0.05)
#             if res != 'ok':
#                 break
#
# # load_data()
#
# save_data()